Skip to content

Deprecate roots, sampling, and logging per SEP-2577 - #406

Draft
atesgoral wants to merge 1 commit into
modelcontextprotocol:mainfrom
atesgoral:issue-390-deprecations
Draft

Deprecate roots, sampling, and logging per SEP-2577#406
atesgoral wants to merge 1 commit into
modelcontextprotocol:mainfrom
atesgoral:issue-390-deprecations

Conversation

@atesgoral

@atesgoral atesgoral commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Deprecate MCP Roots, Sampling, and Logging when protocol version 2026-07-28 or a later protocol version is negotiated or explicitly configured.

Context

SEP-2577 deprecates Roots, Sampling, and Logging as of the 2026-07-28 protocol version while keeping them fully functional during the deprecation window.

Closes #390

Changes

  • Add a shared protocol deprecation helper with 2026-07-28 as the deprecation threshold.
  • Warn on deprecated server APIs and session-scoped calls for roots, sampling, and logging.
  • Warn when deprecated client capabilities or the server logging capability are negotiated, including the nested task-sampling capability shape.
  • Preserve the validated protocol version across stateful and stateless transports without changing wire behavior.
  • Suppress warnings when the version is older or has never been established, and report application call sites rather than SDK internals.
  • Add regression coverage for older, threshold, future, missing-version, stateful, and stateless paths.

Testing

  • ruby -c for all changed Ruby files
  • Direct Ruby smoke checks for stateful/stateless protocol propagation, capability warnings, future versions, and missing-version suppression
  • git diff --check
  • Full test and RuboCop coverage via CI; the local gem environment cannot currently satisfy the bundle

@atesgoral
atesgoral force-pushed the issue-390-deprecations branch 4 times, most recently from d8066ae to 6cabe09 Compare June 14, 2026 15:04
@atesgoral
atesgoral changed the base branch from main to rubocop-cleanup-existing-offenses June 14, 2026 15:04
@atesgoral
atesgoral force-pushed the rubocop-cleanup-existing-offenses branch from 0e694e3 to 460adaf Compare June 14, 2026 15:46
@atesgoral
atesgoral force-pushed the issue-390-deprecations branch 2 times, most recently from 26a27ad to 9533204 Compare June 15, 2026 07:03
@atesgoral
atesgoral changed the base branch from rubocop-cleanup-existing-offenses to main June 15, 2026 07:03
@atesgoral
atesgoral force-pushed the issue-390-deprecations branch 5 times, most recently from 0c7a871 to be41c3c Compare June 15, 2026 08:25
@atesgoral
atesgoral marked this pull request as ready for review June 15, 2026 08:29
@atesgoral
atesgoral requested a review from koic June 15, 2026 08:30
@atesgoral atesgoral changed the title feat: deprecate roots, sampling, and logging for 2026-07-28 feat: deprecate roots, sampling, and logging per SEP-2577 Jun 16, 2026
@atesgoral atesgoral changed the title feat: deprecate roots, sampling, and logging per SEP-2577 Deprecate roots, sampling, and logging per SEP-2577 Jun 16, 2026
@atesgoral

Copy link
Copy Markdown
Contributor Author

@koic Happy to push this through or were you thinking of doing the deprecation later?

@koic

koic commented Jun 24, 2026

Copy link
Copy Markdown
Member

I'd lean toward doing the deprecation later rather than merging the full behavior change now.

This SEP introduces a behavioral switch tied to protocol versioning, and I think that design makes sense because it preserves compatibility with existing protocol versions. However, the 2026-07-28 specification hasn't actually been released yet, and it doesn't appear to have been added to SUPPORTED_STABLE_PROTOCOL_VERSIONS in the Python or TypeScript SDKs either.

Given that, I'd prefer to wait until the 2026-07-28 release is closer before enabling the deprecation behavior.

In the meantime, it might be reasonable to land the advisory annotations on their own.

@atesgoral

Copy link
Copy Markdown
Contributor Author

@koic Sounds good! I can split out the advisory.

@atesgoral
atesgoral marked this pull request as draft June 26, 2026 22:25
atesgoral added a commit to atesgoral/ruby-sdk that referenced this pull request Jun 27, 2026
Split the advisory YARD @deprecated annotations out of modelcontextprotocol#406 so the
documentation can land ahead of the 2026-07-28 protocol release.

Per maintainer feedback, this drops the protocol-version-gated runtime
Kernel.warn behavior and the new 2026-07-28 supported protocol version,
leaving only the @deprecated notes for the Roots, Sampling, and Logging
APIs deprecated by SEP-2577.

Refs modelcontextprotocol#390

Co-authored-by: 🦞 Qlaw <noreply@qlaw.quick.shopify.io>
@atesgoral

Copy link
Copy Markdown
Contributor Author

Split the advisory annotations out into #429 so they can land independently of the protocol-version behavior change. I'll keep this PR open for the 2026-07-28-gated runtime warnings and rebase it once that release is closer.

koic added a commit that referenced this pull request Jul 15, 2026
## Motivation and Context

The MCP specification defines `sampling/createMessage` as a server-to-client request
that lets a server ask the client to generate an LLM completion, so the server can leverage
the client's model access without its own API keys.
The Ruby SDK already supports the server side (sending the request) and, on the client side,
the generic server-to-client request infrastructure introduced for elicitation
(the standalone GET SSE listening stream and `on_server_request` dispatch).
This adds the client-side `sampling/createMessage` handler on top of that infrastructure.

## Changes

- Add `MCP::Client#on_sampling`, a thin wrapper that registers a `sampling/createMessage` handler
  via `transport.on_server_request`, mirroring `on_elicitation`. The handler receives the request params
  and returns a `CreateMessageResult`-shaped Hash sent back as the JSON-RPC result.
- Document client-side sampling in the README, including the `sampling` (and `sampling.tools`)
  capability declaration and the human-in-the-loop guidance from the specification.

## How Has This Been Tested?

- Unit tests for `on_sampling` covering handler registration on the transport
  and the error raised when the transport does not support server-to-client requests.
- An HTTP transport test that dispatches a `sampling/createMessage` server request delivered on
  the SSE stream and returns a `CreateMessageResult`.

## Deprecation Note

SEP-2577 deprecates sampling (along with roots and logging) starting with protocol version `2026-07-28`.
The deprecation warnings are added in #406.
Sampling remains fully supported under the current `2025-11-25` protocol version and stays available
throughout the spec's deprecation window, so the client side is implemented here for parity with
the server side and with the Python and TypeScript SDKs.

`MCP::Client#on_sampling` carries the same `@deprecated` annotation as the server-side senders
annotated in #429, tailored to the receiving side: the handler exists to interoperate with servers
that still send sampling requests during the deprecation window. The README section carries
the same note.

Ref: https://modelcontextprotocol.io/specification/2025-11-25/client/sampling
@atesgoral
atesgoral force-pushed the issue-390-deprecations branch from be41c3c to 9bdcb55 Compare July 23, 2026 01:44
@atesgoral
atesgoral marked this pull request as ready for review July 23, 2026 01:47
@atesgoral

Copy link
Copy Markdown
Contributor Author

@koic Are we ready for this?

@koic

koic commented Jul 23, 2026

Copy link
Copy Markdown
Member

I plan to release MCP Ruby SDK v1.0 tomorrow (#470). I will merge this PR once both Ruby SDK v1.0 and the MCP 2026-07-28 specification have been released. Thank you for your patience.

@koic

koic commented Aug 1, 2026

Copy link
Copy Markdown
Member

I've merged #476. I think it would make sense to include this change in v1.2.0 instead.

Could you please rebase this PR onto the latest main branch?

Also, since changelog entries are added at release time, it might be better not to include one here to avoid merge conflicts.

Comment thread lib/mcp/protocol_deprecations.rb Outdated
}.freeze

def deprecated_roots_sampling_logging?(protocol_version)
protocol_version == Configuration::ROOTS_SAMPLING_LOGGING_DEPRECATED_PROTOCOL_VERSION

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this should support not only the 2026-07-28 specification, but also future specification versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding it

@atesgoral
atesgoral force-pushed the issue-390-deprecations branch from 9bdcb55 to 445e609 Compare August 1, 2026 14:25
@atesgoral
atesgoral marked this pull request as draft August 1, 2026 15:13
@atesgoral
atesgoral force-pushed the issue-390-deprecations branch from 445e609 to 126e841 Compare August 1, 2026 16:38
Warn when Roots, Sampling, or Logging APIs and capabilities are used with MCP protocol version 2026-07-28 or newer.

Cover stateful and stateless transports, preserve behavior for older or unavailable protocol versions, and add regression tests for capability shapes, warning call sites, and future versions.

Closes modelcontextprotocol#390

Co-authored-by: Qlaw <noreply@qlaw.quick.shopify.io>
@atesgoral
atesgoral force-pushed the issue-390-deprecations branch from 126e841 to 3e15286 Compare August 1, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SEP-2577: Deprecate Roots, Sampling, and Logging

2 participants